import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:kkhousekeep/models/member_list_entity.dart';


class MemberItem extends StatefulWidget {
  MemberItem(this._member, this.onTap, {this.segue = false})
      : super(key: ValueKey(_member));
  final MemberListObjList _member;
  final GestureTapCallback? onTap;
  final bool segue; //跳转

  @override
  State<StatefulWidget> createState() {
    return _MemberItemState();
  }
}

class _MemberItemState extends State<MemberItem> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: widget.onTap,
      child: Container(
        height: 176.h,
        padding: EdgeInsets.only(left: 32.w, right: 24.w),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(16.w), color: Colors.white),
        child: Row(
          children: [
            CircleAvatar(
              radius: 48.w,
              backgroundImage: CachedNetworkImageProvider(widget._member.image),
            ),
            SizedBox(width: 32.w),
            Expanded(
                child: Text(
              widget._member.name,
              style: TextStyle(fontSize: 32.sp, color: const Color(0xFF999999)),
            )),
            widget.segue
                ? Image(
                    image: const AssetImage(
                        'assets/images/icon_segue_arrow_grey.png'),
                    width: 48.h,
                    height: 48.h,
                    fit: BoxFit.contain,
                  )
                : Container()
          ],
        ),
      ),
    );
  }
}
